package com.woniu.util;


public class ResponseResult<T> {


    private int status;
    private String msg;
    private T data;


    public ResponseResult(){}


    public int getStatus ( ) {
        return status;
    }

    public void setStatus (int status) {
        this.status = status;
    }

    public String getMsg ( ) {
        return msg;
    }

    public void setMsg (String msg) {
        this.msg = msg;
    }

    public T getData ( ) {
        return data;
    }

    public void setData (T data) {
        this.data = data;
    }

    public static ResponseResult<Void> getSUCCESS ( ) {
        return SUCCESS;
    }

    public static void setSUCCESS (ResponseResult<Void> SUCCESS) {
        ResponseResult.SUCCESS = SUCCESS;
    }

    public static ResponseResult<Void> getInteverError ( ) {
        return INTEVER_ERROR;
    }

    public static void setInteverError (ResponseResult<Void> inteverError) {
        INTEVER_ERROR = inteverError;
    }

    public static ResponseResult<Void> getNotFound ( ) {
        return NOT_FOUND;
    }

    public static void setNotFound (ResponseResult<Void> notFound) {
        NOT_FOUND = notFound;
    }


    public ResponseResult(int status, String msg){
        this.status = status;
        this.msg = msg;
    }
    public ResponseResult(T data, String msg, int status){
        this(status,msg);
        this.data = data;
        this.msg = msg;
    }

    public static ResponseResult ok(){
        ResponseResult result = new ResponseResult();
        result.setStatus(ResultCode.SUCCESS.getCode());
        result.setMsg(ResultCode.SUCCESS.getMessage());
        return result;
    }

    public static ResponseResult error(ResultCode resultCode){
        ResponseResult result = new ResponseResult();
        result.setStatus(resultCode.getCode());
        result.setMsg(resultCode.getMessage());
        return result;
    }

    public static ResponseResult<Void> SUCCESS = new ResponseResult<>(200,"成功");
    public static ResponseResult<Void> INTEVER_ERROR = new ResponseResult<>(500,"服务器错误");
    public static ResponseResult<Void> NOT_FOUND = new ResponseResult<>(404,"未找到");

}
